package com.ruoyi.news.enums;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @version 1.0
 * @Author lijuntao
 * @Date 2025/6/21 19:49
 */
@AllArgsConstructor
public enum NewsStatus {
    // 删除、正常、发布、延时发布
    DELETED(1, "删除"),
    NORMAL(2, "正常"),
    PUBLISH(3, "发布"),
    DELAY_PUBLISH(4, "延时发布");


    private int code;
    private String desc;


    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
    // 判断函数
    public static NewsStatus fromString(String status) {
        for (NewsStatus value : values()) {
            if (value.name().equalsIgnoreCase(status)) {
                return value;
            }
        }
        throw new IllegalArgumentException("无效的状态值: " + status);
    }

}